package cate.game.play.skill.passive.fairy;

import cate.common.table.d.GDSkill;
import cate.game.play.buff.Buff;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.skill.passive.common.立即复活PH;

/**
 * 效果1：【虚弱】不再减少受到的伤害；
 * 效果2：纽伦堡香肠奇数回合死亡后以极低血量复活，最多5次，优先触发其他复活技能
 */
public class 纽伦堡香肠灵器PH extends 立即复活PH {

	private String 虚弱标签;

	private int 次数;

	private double 恢复系数;

	//虚弱标签=虚弱&次数=5&恢复系数=？？
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		虚弱标签 = args.get("虚弱标签");
		次数 = args.getInt("次数", 0);
		恢复系数 = args.getWDouble("恢复系数", 0d);
	}

	@Override
	public void adjustCastBuff(ActionCtx action, Buff otherBuff) {
		if (!otherBuff.cfg.containTag(虚弱标签)) {
			return;
		}
		otherBuff.cfg.enhance.addExAttr(otherBuff.cfg.getExAttr().copy().scale(-1));
	}

	@Override
	protected double healValue() {
		return skill.owner.attr.total().hpTotal()*恢复系数;
	}

	@Override
	protected int getResurrectMax() {
		return 次数;
	}

	@Override
	protected boolean allowResurrect(ActionCtx action) {
		return action.getRound().isOddRound();
	}

	@Override
	public int priority() {
		return GDSkill.Priority.LOW;
	}
}
